
/**
 * 
 * @param {String} url 图片地址
 * @param {Boolean} isPrefix 是否加前缀
 */
export function urlTobase64(url, isPrefix = true){
    return new Promise((resolve, reject) => {
		uni.request({
			url: url,
			method:'GET',
			responseType: 'arraybuffer',
			success: ress => {
				let base64 = wx.arrayBufferToBase64(ress.data); //把arraybuffer转成base64 
				base64 = isPrefix ? 'data:image/jpeg;base64,' + base64 : base64  //不加上这串字符，在页面无法显示的哦
				resolve({
					code: 200, data: base64
				})
			},
			fail: err => {
				reject(err)
			}
		})
	})
}